use hyper::{Client, client::HttpConnector};
use hyper_tls::HttpsConnector;
use crate::middleware::error::Error;
pub type MyHttps = Client<HttpsConnector<HttpConnector>>;


pub fn get_https_client()->MyHttps{
    let https = HttpsConnector::new();
    let client = Client::builder().build::<_, hyper::Body>(https);
    return client
}

//读取body数据
pub async fn read_get_body(client:&MyHttps, uri:hyper::Uri) -> Result<String,Error> {
    let resp = client.get(uri).await?;
    let body_bytes = hyper::body::to_bytes(resp.into_body()).await?;
    let string =  String::from_utf8(body_bytes.to_vec())?;
    Ok(string)
}
